@{ViewBag.Title = " UnidadMilitar ";
  Layout = "../Shared/_LayoutJtable.cshtml";
  }
<div class="filtering"><form>
<label>Introduzca texto para filtrar: <input type="text" name="filter" id="filter" /></label>
<button type="submit" id="LoadRecordsButton" class="button medium orange" >Buscar Coincidencias</button>
</form></div>
<div id="MyTableContainer"></div>
<script type="text/javascript">
     $(document).ready(function () {
     $('#MyTableContainer').jtable({
         title: 'SmtpConfig',
         paging: true,
         pageSize: 10,
         sorting: true,
         defaultSorting: 'Id ASC',
         actions: {
             listAction: '@Url.Action("JSONPagedListByFilter")',
             //deleteAction: '@Url.Action("JSONDelete")',
             updateAction: '@Url.Action("JSONUpdate")',
             createAction: '@Url.Action("JSONCreate")'
         },
         fields:
         {
          Id: {
                 key: true,
                 create: false,
                 edit: false,
                 list: false
             }
             ,
             HostName: {
                 title:'HostName',
                 create: true,
                 edit: true,
                 list: true,
                 inputClass: 'validate[required]',
                 sorting: false
             }
             ,
             DefaultUserName: {
                 title:'DefaultUserName',
                 create: true,
                 edit: true,
                 list: true,
                 inputClass: 'validate[required]',
                 sorting: false
             }
             ,
             DefaultUserPassword: {
                 title:'DefaultUserPassword',
                 create: true,
                 edit: true,
                 list: false,
                 inputClass: 'validate[required]',
                 sorting: false
             }
             ,
             IsSSLEnabled: {
                 title:'IsSSLEnabled',
                 create: true,
                 edit: true,
                 list: true,
                 type: 'checkbox',
                 values:{'false':'Desactivado','true':'Activado'},
                 sorting: false
             }
             ,
             AdministratorEmail: {
                 title:'AdministratorEmail',
                 create: true,
                 edit: true,
                 list: true,
                 inputClass: 'validate[required]',
                 sorting: false
             }
             ,
             SendTestEmail:
             {
                 title: 'Test Mail',
                 width: '60px',
                 sorting: false,
                 edit: false,
                 create: false,
                 listClass: 'child-opener-image-column',
                 display: function (tempData) {
                     var $img = $('<img class="child-opener-image" with="20" height="20" src="../Content/images/ok.png" title="Enviar Email de Test al Administrador" />');
                     $img.click(function () {
                         SendTestEmail();
                     });

                     return $img;
                 }
             }

},
formCreated: function (event, data) {data.form.validationEngine();},
formSubmitting: function (event, data) {return data.form.validationEngine('validate');},
formClosed: function (event, data) { data.form.validationEngine('hide'); data.form.validationEngine('detach'); }
});
$('#LoadRecordsButton').click(function (e) {e.preventDefault();$('#MyTableContainer').jtable('load', {filter: $('#filter').val()});});
$('#LoadRecordsButton').click();


    function SendTestEmail()
    {
    
        $.ajax({
            url: 'SendTestEmail',
            contentType: 'application/json',
            type: 'POST'      
        })
       .success(function (result) {
           if (result.Result == 'ERROR') {
               DidsoftShowDialog('Error', result.Message);
           }
           else{               
               DidsoftShowDialog('Enviado', 'Se ha enviado un email de test al administrador');
           }
       })
       .error(function (xhr, status) {
           alert('Service is not avalable!!!')
       });

    }

    var busyIndicator = '<div id="busyIndicator" data-url="busyIndicator"><h1>Enviando Email, espere por favor</h1></div>';
    $(busyIndicator).appendTo('body');
      

     });

    $(document).ajaxStart(function () {
        $('#busyIndicator').show();
    }).ajaxStop(function () {
        $('#busyIndicator').hide();
    });


</script>

